package model;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.Sprite;

public class Part {
	public int m_iImgId;
	
	public int m_iW;
	public int m_iH;
	public int m_iX;
	public int m_iY;
	
	public int m_nFrame = 1;
	
	public byte[] m_arrDeltaX;
	public byte[] m_arrDeltaY;
	
	public Part(){
		m_arrDeltaX = new byte[5];
		m_arrDeltaY = new byte[5];
	}
	
	public int getX(int action, int x, int trans){
		return x + m_arrDeltaX[action] - (trans == Sprite.TRANS_MIRROR ? m_arrDeltaX[action] * 2 + m_iW : 0);
	}
	
	public void paintPart(Graphics g, int frame, int action, int x, int y, int trans){
		g.drawRegion(DataManager.gI().getImage(m_iImgId), m_iX, m_iY + frame * m_iH, m_iW, m_iH, trans, x + m_arrDeltaX[action] - (trans == Sprite.TRANS_MIRROR ? m_arrDeltaX[action] * 2 + m_iW : 0), y + m_arrDeltaY[action], 20);
	}
	
	//paint trong shop
	public void paintPart(Graphics g, int frame, int x, int y, int trans){
		g.drawRegion(DataManager.gI().getImage(m_iImgId), m_iX, m_iY + frame * m_iH, m_iW, m_iH, trans, x, y, 20);
	}
}
